<template>
  <div class="login-container">
    <form @submit.prevent="login">
      <h1>登录</h1>
      <div class="input-group">
        <label for="username">用户名:</label>
        <input type="text" id="username" v-model="credentials.username" required>
      </div>
      <div class="input-group">
        <label for="password">密码:</label>
        <input type="password" id="password" v-model="credentials.password" required>
      </div>
      <button type="submit">登录</button>
    </form>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      credentials: {
        username: '',
        password: ''
      }
    };
  },
  methods: {
    login() {
      // 这里应该是发送登录请求的代码，例如使用axios
      // this.$http.post('/login', this.credentials)
      //   .then(response => {
      //     // 登录成功的处理逻辑
      //   })
      //   .catch(error => {
      //     // 登录失败的处理逻辑
      //   });
      console.log('登录信息:', this.credentials);
    }
  }
};
</script>
 
<style scoped>
.login-container {
  padding: 20px;
}
 
form {
  display: flex;
  flex-direction: column;
}
 
.input-group {
  margin-bottom: 15px;
}
 
label {
  display: block;
  margin-bottom: 5px;
}
 
input {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}
 
button {
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
 
button:hover, button:focus {
  background-color: #0056b3;
}
</style>